﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Client_Web.ServiceReference;

namespace Client_Web.Account
{
    public partial class CustomRegister : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CreateUser_Click(object sender, EventArgs e)
        {
            ServiceClient serviceClient = new ServiceClient();

            int userId;
            string result = serviceClient.addUser(Name.Text, Login.Text, Password.Text);
            int.TryParse(result, out userId);

            if (0 < userId)
            {
                Session["userId"] = userId;
                Session["userIdStr"] = result;                
                Session["userLogin"] = Login.Text;

                Response.Redirect("~/Default.aspx");
            }
            else
            {
                FailureText.Text = "Erreur à l'inscription !";
            }
        }
    }
}